#ifndef SSLBASE_H
#define SSLBASE_H

#include <defs/export.h>
#include <defs/global.h>

#include <core/entityobject.h>
#include <QtCore>
#include <QUrl>
#include <QtNetwork/QSslSocket>
#include "common.h"

namespace Opl
{
    namespace Helpers
    {
        namespace Ssl
        {
            O_PRIVATE_DECLARE(SslBase);
            class HELPERS_EXPORT SslBase : public Opl::Core::EntityObject
            {
                    Q_OBJECT
                public:
                    SslBase(QSslSocket* socket = 0);
                    virtual ~SslBase();
                    Opl::Helpers::ConnectionStatus status()const;
                    QSslSocket* socket()const;

                public slots:
                    virtual void start();
                    virtual void stop();
                    void Send(const QString& data);

                private slots:
                    void ready();
                    void sslErrors(const QList<QSslError>& errors);
                    void modeChanged (QSslSocket::SslMode mode);
                    void peerVerifyError (const QSslError& error);
                    void socketConnected();
                    void socketDisconnected();
                    void error(QAbstractSocket::SocketError socketError);
                    void hostFound();
                    void proxyAuthenticationRequired (const QNetworkProxy& proxy, QAuthenticator* authenticator);
                    void stateChanged(QAbstractSocket::SocketState socketState);
                    void readyCommand();

                signals:
                    void connected();
                    void disconnected();
                    void error();
                    void output(const QString& data);

                protected:
                    void setSocket(QSslSocket* s);

                    void setStatusInternal(Opl::Helpers::ConnectionStatus s);

                private:
                    O_PRIVATE_DECLARE_MEMBER(SslBase)
            };

        }
    }
}
#endif // SSLBASE_H

